package com.tmt.im.common.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tmt.im.common.annotation._AllowUpdate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.apache.ignite.cache.query.annotations.QuerySqlField;

import java.io.Serial;
import java.sql.Timestamp;

/**
 * @Description TODO
 * @Author wuyi
 * @Date 2024/9/2 16:52
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class IMFriendPoJo implements IGetKey<IMFriendKey> {

    @Serial
    private static final long serialVersionUID = 982949682209411709L;
    public static final String CACHE_NAME = "im_friend";

    @QuerySqlField(name = "id", index = true)
    private Long id;

    @QuerySqlField(name = "id", index = true)
    @JsonIgnore
    private Long mid;

    /**
     * owner设置的好友的备注/别名
     */
    @QuerySqlField(name = "alias")
    @_AllowUpdate
    private String alias;

    /**
     * 免打扰状态
     */
    @QuerySqlField(name = "no_disturbing")
    @_AllowUpdate
    private boolean noDisturbing = false;

    /**
     * friend用户发送的信息是否在owner好友列表中置顶。
     */
    @QuerySqlField(name = "hold_in_top")
    @_AllowUpdate
    private boolean holdInTop = false;

    /**
     * 是否在黑名单中
     */
    @QuerySqlField(name = "in_black_bill")
    @_AllowUpdate
    private boolean inBlackBill = false;

    /**
     * 好友ID
     */
    @QuerySqlField(name = "friend_id")
    private Long friendId;

    /**
     * 本条好友记录的拥有者ID。
     */
    @QuerySqlField(name = "owner_id")
    private Long ownerId;

    /**
     * 关联的好友申请记录ID
     */
    @QuerySqlField(name = "friend_apply_id")
    private Long friendApplyId;

    @QuerySqlField(name = "create_time")
    private Timestamp createTime;

    @QuerySqlField(name = "version")
    @_AllowUpdate
    private Long version;

    @JsonIgnore
    private boolean insert;

    @Override
    public IMFriendKey getKey() {
        return new IMFriendKey(id, ownerId);
    }
}
